import 'package:ls_work/a_yyt/models/dynamic_entity.dart';

class CareReportEntity {
  final int? total;
  List<CareInfo>? rows;

  CareReportEntity({this.rows, this.total});

  factory CareReportEntity.fromJson(Map<String, dynamic> json) {
    final originList = json['rows'] as List?;
    List<CareInfo> protocolList =
        (originList??[]).map((value) => CareInfo.fromJson(value)).toList();
    return CareReportEntity(rows: protocolList, total: json['total']);
  }
}

class CareInfo {
  BeanInfo? bean;

  CareInfo({
    this.bean,
  });

  factory CareInfo.fromJson(Map<String, dynamic> json) {
    return CareInfo(bean: BeanInfo.fromJson(json['bean']));
  }
}

class BeanInfo {
  String? elderName;
  String? bedNo;
  String? recorder;
  String? content;
  int? id;
  int? customerElderId;
  String? recordTime;
  String? createdDate;
  bool? delete;


  ///交接班项目
  int? age;
  int? sex;
  String? nurseLevelName;
  //nurserRecordIsbars
  List<HandoverDetail>? nurserRecordIsbars;
  List<PictureInfo>? attachList;


  BeanInfo({
    this.elderName,
    this.id,
    this.bedNo,
    this.recorder,
    this.content,
    this.customerElderId,
    this.recordTime,
    this.createdDate,

    ///
    this.age,
    this.sex,
    this.nurseLevelName,
    this.nurserRecordIsbars,
    this.attachList,
    this.delete,
  });

  factory BeanInfo.fromJson(Map<String, dynamic> json) {
    final originList1 = json['attachList'] as List?;
    print('🍉' * 20);
    print(json['nurserRecordIsbars']);

    final originList = json['nurserRecordIsbars'] != null
        ? json['nurserRecordIsbars'] as List
        : [];
    List<PictureInfo> photoList = [];
    if (originList1 != null)
      photoList =
          originList1.map((value) => PictureInfo.fromJson(value)).toList();
    List<HandoverDetail> protocolList =
        originList.map((value) => HandoverDetail.fromJson(value)).toList();

    return BeanInfo(
        attachList: photoList ?? [],
        nurserRecordIsbars: protocolList ?? [],
        bedNo: json['bedNo'],
        recorder: json['recorder'],
        content: json['content'],
        customerElderId: json['customerElderId'],
        recordTime: json['recordTime'],
        createdDate: json['createdDate'],
        id: json['id'],

        ///
        age: json['age'],
        sex: json['sex'],
        elderName: json['elderName'],
        delete: json['delete'],
        nurseLevelName: json['nurseLevelName']);
  }
}

class HandoverDetail {
  String? shifter;
  String? successor;
  String? shiftTime;
  String? successionTime;
  int? id;
  int? status;
  String? elderName;
  String? detail;

  HandoverDetail({
    this.shifter,
    this.id,
    this.status,
    this.successor,
    this.shiftTime,
    this.successionTime,
    this.elderName,
    this.detail,
  });

  HandoverDetail.fromJson(Map data) {
    shifter = data['shifter'];
    successor = data['successor'];
    shiftTime = data['shiftTime'];
    successionTime = data['successionTime'];
    detail = data['detail'];
    elderName = data['elderName'];
    id = data['id'];
    status = data['status'];
  }
}
